package router

import "github.com/gin-gonic/gin"

var routes = make(map[string]IRouters)

func InitRouters() {
	openRouters := new(OpenRouters)
	adminRouters := new(AdminRouters)
	homeRouters := new(HomeRouters)

	openRouters.SetName()
	adminRouters.SetName()
	homeRouters.SetName()

	routes[openRouters.GetName()] = openRouters
	routes[adminRouters.GetName()] = adminRouters
	routes[homeRouters.GetName()] = homeRouters
}

func registerRouters(r *gin.Engine) {
	for _, v := range routes {
		v.SetGroupName(r)
		v.InitRouters()
	}
}

func Router(r *gin.Engine) {
	InitRouters()
	registerRouters(r)
}
